//
//  HomeCrowdfundingViewController.m
//  ioschishan
//
//  Created by 马田成 on 2017/7/11.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeCrowdfundingViewController.h"
#import "HomeCrowdFundingFirstCell.h"
#import "RemarksCellHeightModel.h"
#import "RemarksTableViewCell.h"
#import "HomeCrowdThreeTableViewCell.h"

#import "HomeCrowdHelpTAVC.h"
#import "MJRefresh.h"
#import "HomeCrowSectionThreeBtn.h"
#import "HomeCrowZCDTCell.h"//1行图片的众筹动态
#import "HomeCrowCKDTTwoCell.h"//2行图片的众筹动态
#import "HomeCKDTThreeCell.h"//3行图片的众筹动态
#import "HomePHBCell.h"//排行榜
#import "HomeTAHelpCell.h"//他的帮助
#import "ProjectUpdateViewController.h"//项目更新


@interface HomeCrowdfundingViewController ()<UITableViewDelegate, UITableViewDataSource,CAAnimationDelegate,RemarksCellDelegate>

{
    BOOL _isShow; // 是否展开
    NSString *_cellContentStr; // 备注消息
    UIView *grayView;
    NSString *type;//3个类型
    NSInteger isOwn;//是不是自己发布
    
}


@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataSource;//内容
@property (nonatomic, strong) NSMutableDictionary *dictData;//上部数据
@property (nonatomic, assign) NSInteger page1;
@property (nonatomic, strong) NSMutableArray *arrOfXM;//筹款动态数据数组
@property (nonatomic, strong) NSMutableArray *arrOfPic1;//上部数据图片
@property (nonatomic, strong) NSMutableArray *arrOfBZ;//帮助数据数组
@property (nonatomic, assign) NSInteger page2;//帮助
@property (nonatomic, strong) NSMutableArray *arrOfPH;//排行榜数据数组
@property (nonatomic, strong) HomeCrowSectionThreeBtn *sectionWork;
@property (nonatomic, assign) NSInteger page3;//排行榜page

@end

@implementation HomeCrowdfundingViewController
- (void)viewWillAppear:(BOOL)animated{

    [self creationXMData];
    
    __weak typeof(self) weakself = self;
    
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        if ([type isEqualToString:@"2"]) {
            [weakself creationBZDataJZ];
            
        }else if ([type isEqualToString:@"3"]){
            [weakself creationPHDataJZ];
        
        }else {
        
            [weakself creationXMDataJZ];
        }
    }];
    
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        
        if ([type isEqualToString:@"2"]) {
            [weakself creationBZData];
            
        }else if ([type isEqualToString:@"3"]){
            [weakself creationPHData];
            
        }else {
            
            [weakself creationXMData];
        }
        
        [self.tableView.mj_header beginRefreshing];
    }];
    

}
- (void)viewDidLoad {
    [super viewDidLoad];
    _page2 = 1;
    _page3 = 1;
    _page1 = 1;
    type = @"1";

    _tableView.mj_header.automaticallyChangeAlpha = YES;
    
    [self creationView];
    [self regeditCell];
    [self creationData];
    
    // Do any additional setup after loading the view.
}

- (void)creationView{

    [self setTitle:@"众筹详情"];
    UIView *viewOf = [[UIView alloc] init];
    viewOf.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, 1);
    [self.view addSubview:viewOf];
    viewOf.backgroundColor = [UIColor colorWithRed:204 / 255.0f green:204 / 255.0f  blue:204 / 255.0f  alpha:1];

    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 1, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 49);
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.estimatedRowHeight = 400;
    [self.view addSubview:self.tableView];
    
    
    UIButton *buttonHelp = [[UIButton alloc] init];
    [self.view addSubview:buttonHelp];
    [buttonHelp setTitle:@"帮助TA" forState:UIControlStateNormal];
    
    buttonHelp.titleLabel.font = [UIFont systemFontOfSize:16];
    buttonHelp.backgroundColor = [UIColor colorWithRed:140 / 255.0f green:215 / 255.0f blue:27 / 255.0f alpha:1];
    
    [buttonHelp setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buttonHelp addTarget:self action:@selector(helpClick) forControlEvents:UIControlEventTouchUpInside];
    
    [buttonHelp mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view);
        make.right.equalTo(self.view);
        make.height.offset(49);
        make.bottom.equalTo(self.view);
        
        
    }];

    UIButton *searchBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, screenScale(40), screenScale(40))];
    searchBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    
    [searchBtn addTarget:self action:@selector(pianoBtnClick) forControlEvents:UIControlEventTouchUpInside];
    
    
    [searchBtn setImage:[UIImage imageNamed:@"more_icon"] forState:UIControlStateNormal];
    
    
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc]initWithCustomView:searchBtn];
    self.navigationItem.rightBarButtonItem = rightItme;
    
    
}
- (void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowdFundingFirstCell" bundle:nil] forCellReuseIdentifier:@"HomeCrowdFundingFirstCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowdThreeTableViewCell" bundle:nil] forCellReuseIdentifier:@"HomeCrowdThreeTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowdFourTableViewCell" bundle:nil] forCellReuseIdentifier:@"HomeCrowdFourTableViewCell"];
    //3个button scetion
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowSectionThreeBtn" bundle:nil] forHeaderFooterViewReuseIdentifier:@"HomeCrowSectionThreeBtn"];
    
    //筹款动态1cell
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowZCDTCell" bundle:nil] forCellReuseIdentifier:@"HomeCrowZCDTCell"];
    
    //筹款动态2cell
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCrowCKDTTwoCell" bundle:nil] forCellReuseIdentifier:@"HomeCrowCKDTTwoCell"];
    //筹款动态3cell
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeCKDTThreeCell" bundle:nil] forCellReuseIdentifier:@"HomeCKDTThreeCell"];
    
    //排行榜cell
    [self.tableView registerNib:[UINib nibWithNibName:@"HomePHBCell" bundle:nil] forCellReuseIdentifier:@"HomePHBCell"];
    
    //TA的帮助cell
    [self.tableView registerNib:[UINib nibWithNibName:@"HomeTAHelpCell" bundle:nil] forCellReuseIdentifier:@"HomeTAHelpCell"];
    
    
    
}


- (void)creationData{
    _dictData = [[NSMutableDictionary alloc] init];
    _arrOfPic1 = [NSMutableArray array];

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;

    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //    NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:_crowd_id forKey:@"crowd_id"];
    
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdDetails networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            _dictData=[returnData objectForKey:@"data"];

            _cellContentStr = [_dictData objectForKey:@"content"];
            
            _arrOfPic1 = [self.dictData objectForKey:@"pic"];
            isOwn = [[self.dictData objectForKey:@"is_own"] intValue];
            
            

            NSLog(@"DDDDDDDDDDDD%@", self.dataSource);
            
            [self.tableView reloadData];
            
            
            [hud removeFromSuperview];
        }
        
        else {
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        [hud removeFromSuperview];
    }];
    
}
//筹款动态
- (void)creationXMData{
    
    //  _dataArr = [NSMutableArray array];
    
    [self.tableView.mj_header endRefreshing];

    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    _arrOfXM = [NSMutableArray array];
    
    _page1 = 1;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:_crowd_id forKey:@"crowd_id"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdupdate networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                
                [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
                [hud removeFromSuperview];
            }else {
                
                _arrOfXM=[returnData objectForKey:@"data"];
                [hud removeFromSuperview];
                
            }

            [self.tableView reloadData];
            [hud removeFromSuperview];
        }
        
        else {
            [self.tableView reloadData];
            [hud removeFromSuperview];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];

            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        [hud removeFromSuperview];
    }];
    
}
- (void)creationXMDataJZ{
    
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    _page1++;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //  NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdupdate networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
   
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                

                [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
                [self.tableView.mj_footer endRefreshing];
                [hud removeFromSuperview];
            }else {
                
                [_arrOfXM addObjectsFromArray:arr];
                NSLog(@"%@", _arrOfXM);
                [hud removeFromSuperview];

                
            }
            
            
            [hud removeFromSuperview];

            [self.tableView reloadData];
            [self.tableView.mj_footer endRefreshing];
            
        }
        
        else {
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
            [hud removeFromSuperview];

            [self.tableView.mj_footer endRefreshing];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
         [hud removeFromSuperview];
    }];
    
}
//帮助ta
- (void)creationBZData{
    
    //  _dataArr = [NSMutableArray array];
    
    [self.tableView.mj_header endRefreshing];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    _arrOfBZ = [NSMutableArray array];
    
    _page2 = 1;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:_crowd_id forKey:@"crowd_id"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdsupport networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                
                [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
                 [hud removeFromSuperview];
            }else {
                
                _arrOfBZ=[returnData objectForKey:@"data"];
                 [hud removeFromSuperview];
            }
            
            
             [self.tableView reloadData];
             [hud removeFromSuperview];
        }
        
        else {
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
             [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
         [hud removeFromSuperview];
    }];
    
}
- (void)creationBZDataJZ{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    _page2++;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //  NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdsupport networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                
                [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
                 [hud removeFromSuperview];
            }else {
                
                [_arrOfBZ addObjectsFromArray:arr];
                 [hud removeFromSuperview];
                NSLog(@"%@", _arrOfBZ);
                
            }

            [self.tableView reloadData];
            
            [self.tableView.mj_footer endRefreshing];
             [hud removeFromSuperview];
            
        }
        
        else {
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
            [self.tableView.mj_footer endRefreshing];
             [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
         [hud removeFromSuperview];
    }];
    
}

//帮助ta
- (void)creationPHData{
    
    //  _dataArr = [NSMutableArray array];
    
    [self.tableView.mj_header endRefreshing];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    _arrOfPH = [NSMutableArray array];
    
    _page3 = 1;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    [productParams setValue:_crowd_id forKey:@"crowd_id"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdranking networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                
                [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
                [hud removeFromSuperview];
            }else {
            
                _arrOfPH=[returnData objectForKey:@"data"];
                [hud removeFromSuperview];
            
            }
            
            [self.tableView reloadData];
            [hud removeFromSuperview];
        }
        
        else {
            
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
            [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
        [hud removeFromSuperview];
    }];
    
}
- (void)creationPHDataJZ{
    
    _page3++;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[[UIApplication sharedApplication]keyWindow] animated:YES];
    hud.tag = 500;
    //提示文本
    hud.labelText = @"正在加载...";
    //是否有遮罩
    hud.dimBackground = YES;
    
    NSString *strPage = [NSString stringWithFormat:@"%ld", (long)_page1];
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //  NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:strPage forKey:@"page"];
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdranking networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            NSMutableArray *arr =[returnData objectForKey:@"data"];
            
            if ([[arr[0] objectForKey:@"member_id"] length] == 0) {
                
                [self.tableView.mj_footer endRefreshing];
                 [hud removeFromSuperview];
            }else {
                
                [_arrOfPH addObjectsFromArray:arr];
                 [hud removeFromSuperview];
                NSLog(@"%@", _arrOfPH);
                
            }
            
            [self.tableView reloadData];
            
            [self.tableView.mj_footer endRefreshing];
             [hud removeFromSuperview];
            
        }
        
        else {
            
            [self.tableView reloadData];
            [PublicFunction showAlert:nil message:@"暂无数据" duration:5.0f];
            [self.tableView.mj_footer endRefreshing];
             [hud removeFromSuperview];
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
         [hud removeFromSuperview];
    }];
    
}




#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{

    
    if (section == 3) {
        return 65;
    }else {
        
        return 0;
        
    }
        
 
}
#pragma mark - ---------- Section的内容 ----------
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if (section == 3) {
        
        self.sectionWork = [self.tableView dequeueReusableHeaderFooterViewWithIdentifier:@"HomeCrowSectionThreeBtn"];

        [self.sectionWork.CKDTBtn addTarget:self action:@selector(ckdtClick) forControlEvents:UIControlEventTouchUpInside];
         [self.sectionWork.TABtn addTarget:self action:@selector(TAClick) forControlEvents:UIControlEventTouchUpInside];
         [self.sectionWork.PhBbtn addTarget:self action:@selector(PhBClick) forControlEvents:UIControlEventTouchUpInside];
        
        if ([type isEqualToString:@"1"]) {
            
            self.sectionWork.PHbView.hidden = YES;
            self.sectionWork.TAView.hidden = YES;
            self.sectionWork.CKDTView.hidden = NO;
        }else if ([type isEqualToString:@"2"]){
            
            self.sectionWork.PHbView.hidden = YES;
            self.sectionWork.TAView.hidden = NO;
            self.sectionWork.CKDTView.hidden = YES;
        
            
        }else {
        
            self.sectionWork.PHbView.hidden = NO;
            self.sectionWork.TAView.hidden = YES;
            self.sectionWork.CKDTView.hidden = YES;
            
        }
        
        
        return self.sectionWork;
        
        
    }
    return nil;
    
    
}



#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    if (section == 3) {
        if ([type isEqualToString:@"1"]) {
            return self.arrOfXM.count;

        }else if ([type isEqualToString:@"2"]){
        
            return self.arrOfBZ.count;
        }else {
        
           return self.arrOfPH.count;
        }
    }else {    
        return 1;
    }

    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        
        return UITableViewAutomaticDimension;
    }else if (indexPath.section == 1){
    
        return [RemarksCellHeightModel cellHeightWith:_cellContentStr andIsShow:_isShow andLableWidth:BOUNDS.size.width-30 andFont:12 andDefaultHeight:52 andFixedHeight:42 andIsShowBtn:8];
        
    }else if (indexPath.section == 2) {
    

        NSMutableArray *a = [self.dictData valueForKey:@"pic"];
        
        if (a.count >6 && a.count<=9) {
            return 190 +234;
            //        return UITableViewAutomaticDimension + 420;
            
        }else if (a.count<= 6 &&a.count>3){
            
            return 190 +117;
            //        return UITableViewAutomaticDimension + 280;
        }else {
            
            return 190;
            //        return UITableViewAutomaticDimension + 340;
        }
        
    }else {
    
        if ([type isEqualToString:@"2"]) {
            
            return 120;
        }else if([type isEqualToString:@"3"]) {
        
            return 66;
            
        }else {
        
            return UITableViewAutomaticDimension;
            
        }

        
        
    }

}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        HomeCrowdFundingFirstCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeCrowdFundingFirstCell" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.address.text = [[self.dictData objectForKey:@"address"] stringByAppendingString:[self.dictData objectForKey:@"school_name"]];
        cell.user_name.text =[self.dictData objectForKey:@"user_name"];
        NSString *urlN1 = manage(AP_HOST,[self.dictData objectForKey:@"header_img"]);
        
        NSURL *urlW1 = [NSURL URLWithString:urlN1];
        [cell.header_img sd_setImageWithURL:urlW1 placeholderImage:[UIImage imageNamed:@"niunai"]];
        cell.title.text = [self.dictData objectForKey:@"title"];
        if ([[self.dictData objectForKey:@"type"] isEqualToString:@"1"]) {
            cell.type.text = @"老师";
        }else {
        
            cell.type.text = @"个人";
        }
        
        cell.days_raised.text = [self.dictData objectForKey:@"days_raised"];
        cell.add_time.text = [self.dictData objectForKey:@"add_time"];
        cell.target.text = [self.dictData objectForKey:@"target"];
        cell.money.text = [self.dictData objectForKey:@"money"];
        cell.support.text = [self.dictData objectForKey:@"support"];
        
        
        
        return cell;
    }else if (indexPath.section == 1){
    
        
        static NSString *cellName = @"meTableViewCell";
        RemarksTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
        if (!cell) {
            cell = [[RemarksTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellName];
            cell.delegate = self;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [cell setCellContent:_cellContentStr andIsShow:_isShow  andCellIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        return cell;
    
    }else if (indexPath.section == 2) {
        HomeCrowdThreeTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeCrowdThreeTableViewCell" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        cell.arrOfPic = _arrOfPic1;
        
        cell.num = [NSString stringWithFormat:@"%lu", (unsigned long)_arrOfPic1.count];

        return cell;
        
    
    }else {
    
        if ([type isEqualToString:@"2"]) {
            
            HomeTAHelpCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeTAHelpCell" forIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            
            NSMutableDictionary *dic =[[NSMutableDictionary alloc] init];
            dic = _arrOfBZ[indexPath.row];
            cell.user_name.text = [dic objectForKey:@"user_name"];
            cell.money.text = [[dic objectForKey:@"money"] stringByAppendingString:@"水滴"];
            
            NSString *urlN1 = manage(AP_HOST,[dic objectForKey:@"header_img"]);
            
            NSURL *urlW1 = [NSURL URLWithString:urlN1];
            [cell.header_img sd_setImageWithURL:urlW1 placeholderImage:[UIImage imageNamed:@"niunai"]];
            cell.user_nameC.text =[dic objectForKey:@"user_name"];

            
            return cell;
        }else if ([type isEqualToString:@"3"]){
        
            HomePHBCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomePHBCell" forIndexPath:indexPath];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            NSMutableDictionary *dic =[[NSMutableDictionary alloc] init];
            dic = _arrOfPH[indexPath.row];
            cell.user_name.text = [dic objectForKey:@"user_name"];
            cell.money.text = [[dic objectForKey:@"money"] stringByAppendingString:@"水滴"];
            
            NSString *urlN1 = manage(AP_HOST,[dic objectForKey:@"header_img"]);
            
            NSURL *urlW1 = [NSURL URLWithString:urlN1];
            [cell.header_img sd_setImageWithURL:urlW1 placeholderImage:[UIImage imageNamed:@"niunai"]];
            
            
            return cell;
            
        }else {
        
            NSMutableArray *arrOfZX = [NSMutableArray array];
            arrOfZX = [self.arrOfXM[indexPath.row] objectForKey:@"pictures"];
            NSMutableDictionary *dictOfZX = [[NSMutableDictionary alloc] init];
            dictOfZX = self.arrOfXM[indexPath.row];
            
            if (arrOfZX.count <= 3) {
                
                HomeCrowZCDTCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeCrowZCDTCell" forIndexPath:indexPath];
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                cell.user_name.text = [dictOfZX objectForKey:@"user_name"];
                cell.add_time.text = [dictOfZX objectForKey:@"add_time"];
                cell.content.text = [dictOfZX objectForKey:@"content"];
                
                NSString *urlHeader = manage(AP_HOST, [dictOfZX objectForKey:@"header_img"]);
                
                [cell.header_img sd_setImageWithURL:[NSURL URLWithString:urlHeader] placeholderImage:[UIImage imageNamed:@"niunai"]];
                if (arrOfZX.count == 1) {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    cell.pic2.hidden = YES;
                    cell.pic3.hidden = YES;
                    
                }else if (arrOfZX.count == 2){
                
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    cell.pic3.hidden = YES;
                    
                }else {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    
                }
                
                
                
                return cell;
                
            }else if (arrOfZX.count > 3 && arrOfZX.count <= 6){
                
                HomeCrowCKDTTwoCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeCrowCKDTTwoCell" forIndexPath:indexPath];
                cell.selectionStyle = UITableViewCellEditingStyleNone;
                cell.user_name.text = [dictOfZX objectForKey:@"user_name"];
                cell.add_time.text = [dictOfZX objectForKey:@"add_time"];
                cell.content.text = [dictOfZX objectForKey:@"content"];
                
                NSString *urlHeader = manage(AP_HOST, [dictOfZX objectForKey:@"header_img"]);
                
                [cell.header_img sd_setImageWithURL:[NSURL URLWithString:urlHeader] placeholderImage:[UIImage imageNamed:@"niunai"]];
                if (arrOfZX.count == 4) {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    cell.pic5.hidden = YES;
                    cell.pic6.hidden = YES;
                    
                    
                }else if (arrOfZX.count == 5){
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic5 = manage(AP_HOST, [arrOfZX[4] objectForKey:@"path"]);
                    [cell.pic5 sd_setImageWithURL:[NSURL URLWithString:urlPic5] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    cell.pic6.hidden = YES;
                    
                    
                }else {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic5 = manage(AP_HOST, [arrOfZX[4] objectForKey:@"path"]);
                    [cell.pic5 sd_setImageWithURL:[NSURL URLWithString:urlPic5] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic6 = manage(AP_HOST, [arrOfZX[5] objectForKey:@"path"]);
                    [cell.pic6 sd_setImageWithURL:[NSURL URLWithString:urlPic6] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                }

                return cell;
                
            
            }else {
                
                HomeCKDTThreeCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"HomeCKDTThreeCell" forIndexPath:indexPath];
                
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                cell.user_name.text = [dictOfZX objectForKey:@"user_name"];
                cell.add_time.text = [dictOfZX objectForKey:@"add_time"];
                cell.content.text = [dictOfZX objectForKey:@"content"];
                
                NSString *urlHeader = manage(AP_HOST, [dictOfZX objectForKey:@"header_img"]);
                
                [cell.header_img sd_setImageWithURL:[NSURL URLWithString:urlHeader] placeholderImage:[UIImage imageNamed:@"niunai"]];
                if (arrOfZX.count == 7) {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic5 = manage(AP_HOST, [arrOfZX[4] objectForKey:@"path"]);
                    [cell.pic5 sd_setImageWithURL:[NSURL URLWithString:urlPic5] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic6 = manage(AP_HOST, [arrOfZX[5] objectForKey:@"path"]);
                    [cell.pic6 sd_setImageWithURL:[NSURL URLWithString:urlPic6] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic7 = manage(AP_HOST, [arrOfZX[6] objectForKey:@"path"]);
                    [cell.pic7 sd_setImageWithURL:[NSURL URLWithString:urlPic7] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    cell.pic8.hidden = YES;
                    cell.pic9.hidden = YES;
                    
                    
                    
                }else if (arrOfZX.count == 8){
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic5 = manage(AP_HOST, [arrOfZX[4] objectForKey:@"path"]);
                    [cell.pic5 sd_setImageWithURL:[NSURL URLWithString:urlPic5] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic6 = manage(AP_HOST, [arrOfZX[5] objectForKey:@"path"]);
                    [cell.pic6 sd_setImageWithURL:[NSURL URLWithString:urlPic6] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic7 = manage(AP_HOST, [arrOfZX[6] objectForKey:@"path"]);
                    [cell.pic7 sd_setImageWithURL:[NSURL URLWithString:urlPic7] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic8 = manage(AP_HOST, [arrOfZX[7] objectForKey:@"path"]);
                    [cell.pic8 sd_setImageWithURL:[NSURL URLWithString:urlPic8] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    cell.pic9.hidden = YES;
                    
                    
                }else {
                    
                    NSString *urlPic1 = manage(AP_HOST, [arrOfZX[0] objectForKey:@"path"]);
                    [cell.pic1 sd_setImageWithURL:[NSURL URLWithString:urlPic1] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic2 = manage(AP_HOST, [arrOfZX[1] objectForKey:@"path"]);
                    [cell.pic2 sd_setImageWithURL:[NSURL URLWithString:urlPic2] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic3 = manage(AP_HOST, [arrOfZX[2] objectForKey:@"path"]);
                    [cell.pic3 sd_setImageWithURL:[NSURL URLWithString:urlPic3] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic4 = manage(AP_HOST, [arrOfZX[3] objectForKey:@"path"]);
                    [cell.pic4 sd_setImageWithURL:[NSURL URLWithString:urlPic4] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic5 = manage(AP_HOST, [arrOfZX[4] objectForKey:@"path"]);
                    [cell.pic5 sd_setImageWithURL:[NSURL URLWithString:urlPic5] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    NSString *urlPic6 = manage(AP_HOST, [arrOfZX[5] objectForKey:@"path"]);
                    [cell.pic6 sd_setImageWithURL:[NSURL URLWithString:urlPic6] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic7 = manage(AP_HOST, [arrOfZX[6] objectForKey:@"path"]);
                    [cell.pic7 sd_setImageWithURL:[NSURL URLWithString:urlPic7] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic8 = manage(AP_HOST, [arrOfZX[7] objectForKey:@"path"]);
                    [cell.pic8 sd_setImageWithURL:[NSURL URLWithString:urlPic8] placeholderImage:[UIImage imageNamed:@"niunai"]];
                    
                    NSString *urlPic9 = manage(AP_HOST, [arrOfZX[8] objectForKey:@"path"]);
                    [cell.pic9 sd_setImageWithURL:[NSURL URLWithString:urlPic9] placeholderImage:[UIImage imageNamed:@"niunai"]];
                }

                return cell;
            }
            
        }

        
    }
    

    
}


#pragma mark -- Dalegate
- (void)remarksCellShowContrntWithDic:(NSDictionary *)dic andCellIndexPath:(NSIndexPath *)indexPath
{
    _isShow = [[NSString stringWithFormat:@"%@",[dic objectForKey:@"isShow"]] boolValue];
    
    [_tableView reloadData];
}


#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
}




//帮助他

- (void)helpClick{

    HomeCrowdHelpTAVC *vc = [[HomeCrowdHelpTAVC alloc] init];
    vc.crowd_id = self.crowd_id;
    
    [self.navigationController pushViewController:vc animated:YES];
    

}
//右边点点

#pragma mark -------------分享------------
- (void)pianoBtnClick{
    
    grayView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT)];
    grayView.backgroundColor = [UIColor colorWithRed:0 / 255.0f green:0 / 255.0f blue:0 / 255.0f alpha:0.2];
    
    [[UIApplication sharedApplication].keyWindow addSubview:grayView];
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissContactView)];
    [grayView addGestureRecognizer:tapGesture];
    
    UIView *viewWhite = [[UIView alloc] init];
    [grayView addSubview:viewWhite];
    viewWhite.backgroundColor = [UIColor whiteColor];
    [viewWhite mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(grayView);
        make.right.equalTo(grayView);
        make.bottom.equalTo(grayView);
        make.height.offset(270);
        
    }];
    //微信
    UIButton *buttonWeiXin = [[UIButton alloc] init];
    [grayView addSubview:buttonWeiXin];
    [buttonWeiXin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(24);
        make.left.equalTo(viewWhite).with.offset(27);
        make.height.offset(32);
        make.width.offset(40);
        
    }];
    
    [buttonWeiXin setBackgroundImage:[UIImage imageNamed:@"wechat"] forState:UIControlStateNormal];
    UILabel *labelWeiXin = [[UILabel alloc] init];
    [grayView addSubview:labelWeiXin];
    labelWeiXin.text = @"微信";
    labelWeiXin.font = [UIFont systemFontOfSize:12];
    [labelWeiXin mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(72);
        make.centerX.equalTo(buttonWeiXin.mas_centerX);
        make.height.offset(17);
        
    }];
    labelWeiXin.textColor = getColor(@"9B9B9B");
    
    //朋友圈
    
    UIButton *buttonFriend = [[UIButton alloc] init];
    [grayView addSubview:buttonFriend];
    [buttonFriend mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(21);
        make.left.equalTo(buttonWeiXin.mas_right).with.offset((DEF_SCREEN_WIDTH - 54 - 160)/ 3 );
        make.height.offset(40);
        make.width.offset(40);
        
    }];
    
    [buttonFriend setBackgroundImage:[UIImage imageNamed:@"pengyouquan"] forState:UIControlStateNormal];
    UILabel *labelFriend  = [[UILabel alloc] init];
    [grayView addSubview:labelFriend];
    labelFriend.text = @"朋友圈";
    labelFriend.font = [UIFont systemFontOfSize:12];
    [labelFriend mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(72);
        make.centerX.equalTo(buttonFriend.mas_centerX);
        make.height.offset(17);
        
    }];
    labelFriend.textColor = getColor(@"9B9B9B");
    
    
    //QQ
    
    UIButton *buttonQQ = [[UIButton alloc] init];
    [grayView addSubview:buttonQQ];
    [buttonQQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(22);
        make.left.equalTo(buttonFriend.mas_right).with.offset((DEF_SCREEN_WIDTH - 54 - 160)/ 3 );
        make.height.offset(38);
        make.width.offset(36);
        
    }];
    
    [buttonQQ setBackgroundImage:[UIImage imageNamed:@"qq"] forState:UIControlStateNormal];
    UILabel *labelQQ  = [[UILabel alloc] init];
    [grayView addSubview:labelQQ];
    labelQQ.text = @"QQ";
    labelQQ.font = [UIFont systemFontOfSize:12];
    [labelQQ mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(72);
        make.centerX.equalTo(buttonQQ.mas_centerX);
        make.height.offset(17);
        
    }];
    labelQQ.textColor = getColor(@"9B9B9B");
    
    //qq空间
    
    UIButton *buttonQQSpace = [[UIButton alloc] init];
    [grayView addSubview:buttonQQSpace];
    [buttonQQSpace mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(20);
        make.left.equalTo(buttonQQ.mas_right).with.offset((DEF_SCREEN_WIDTH - 54 - 160)/ 3 );
        make.height.offset(38);
        make.width.offset(41);
        
    }];
    
    [buttonQQSpace setBackgroundImage:[UIImage imageNamed:@"qzone"] forState:UIControlStateNormal];
    UILabel *labelQQSpace  = [[UILabel alloc] init];
    [grayView addSubview:labelQQSpace];
    labelQQSpace.text = @"QQ空间";
    labelQQSpace.font = [UIFont systemFontOfSize:12];
    [labelQQSpace mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(viewWhite).with.offset(72);
        make.centerX.equalTo(buttonQQSpace.mas_centerX);
        make.height.offset(17);
        
    }];
    labelQQSpace.textColor = getColor(@"9B9B9B");
    
    UIView *oneView = [[UIView alloc] init];
    [viewWhite addSubview:oneView];
    oneView.backgroundColor = getColor(@"CCCCCC");
    [oneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(viewWhite).with.offset(15);
        make.right.equalTo(viewWhite).with.offset(-15);
        make.height.offset(1);
        make.top.equalTo(labelQQSpace.mas_bottom).with.offset(20);
        
    }];
    
    //收藏
    
    if (isOwn == -1) {
        
        UIButton *buttonCollect = [[UIButton alloc] init];
        [grayView addSubview:buttonCollect];
        [buttonCollect mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(oneView.mas_bottom).with.offset(24);
            make.centerX.equalTo(buttonWeiXin.mas_centerX);
            make.height.offset(48);
            make.width.offset(48);
            
        }];
        [buttonCollect addTarget:self action:@selector(CollectClick) forControlEvents:UIControlEventTouchUpInside];
        
        [buttonCollect setBackgroundImage:[UIImage imageNamed:@"collect"] forState:UIControlStateNormal];
        UILabel *labelCollect  = [[UILabel alloc] init];
        [grayView addSubview:labelCollect];
        labelCollect.text = @"收藏";
        labelCollect.font = [UIFont systemFontOfSize:12];
        [labelCollect mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(oneView.mas_bottom).with.offset(72);
            make.centerX.equalTo(buttonCollect.mas_centerX);
            make.height.offset(17);
            
        }];
        labelCollect.textColor = getColor(@"9B9B9B");
    }else {
    
        UIButton *buttonCollect = [[UIButton alloc] init];
        [grayView addSubview:buttonCollect];
        [buttonCollect mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(oneView.mas_bottom).with.offset(24);
            make.centerX.equalTo(buttonWeiXin.mas_centerX);
            make.height.offset(48);
            make.width.offset(48);
            
        }];
        
        [buttonCollect setBackgroundImage:[UIImage imageNamed:@"yanzhegn"] forState:UIControlStateNormal];
        [buttonCollect addTarget:self action:@selector(projectUpdate) forControlEvents:UIControlEventTouchUpInside];
        UILabel *labelCollect  = [[UILabel alloc] init];
        [grayView addSubview:labelCollect];
        labelCollect.text = @"项目更新";
        labelCollect.font = [UIFont systemFontOfSize:12];
        [labelCollect mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(oneView.mas_bottom).with.offset(72);
            make.centerX.equalTo(buttonCollect.mas_centerX);
            make.height.offset(17);
            
        }];
        labelCollect.textColor = getColor(@"9B9B9B");
        
    }
    
    
    UIView *twoView = [[UIView alloc] init];
    [viewWhite addSubview:twoView];
    twoView.backgroundColor = getColor(@"CCCCCC");
    [twoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(viewWhite);
        make.right.equalTo(viewWhite);
        make.height.offset(1);
        make.top.equalTo(oneView.mas_bottom).with.offset(109);
        
    }];
    
    UIButton *buttonCancel = [[UIButton alloc] init];
    [viewWhite addSubview:buttonCancel];
    [buttonCancel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(viewWhite);
        make.right.equalTo(viewWhite);
        make.bottom.equalTo(viewWhite);
        make.top.equalTo(twoView.mas_bottom).with.offset(1);
        
    }];
    [buttonCancel setTitle:@"取消" forState:UIControlStateNormal];
    
    buttonCancel.titleLabel.font = [UIFont systemFontOfSize:16];
    buttonCancel.backgroundColor = [UIColor whiteColor];
    [buttonCancel setTitleColor:getColor(@"4A4A4A") forState:UIControlStateNormal];
    
    [buttonCancel addTarget:self action:@selector(dismissContactView) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (void)dismissContactView {
    
    [grayView removeFromSuperview];
}
//筹款动态
- (void)ckdtClick{
    type = @"1";

    [self creationXMData];
    

}
//排行榜
- (void)PhBClick{
    type = @"3";
    
    
    [self creationPHData];
    

}
//帮助他

- (void)TAClick{
    type = @"2";
    
    [self creationBZData];

}
#pragma mark ---------收藏---------
- (void)CollectClick{

    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *token = [PublicFunction getConfigWithKey:@"token"];
    //    NSString *str = @"917b0ddccade4345b1b066fdc4971a14";
    
    [productParams setValue:token forKey:@"token"];
    [productParams setValue:_crowd_id forKey:@"crowd_id"];
    
    [[MNetworkHandler sharedInstance]conURL:home_CrowdCrowdcollection networkType:NetWorkPOST params:productParams delegate:nil showHUD:NO successBlock:^(id returnData) {
        
        if ([[returnData objectForKey:@"code"]intValue]==1) {
            
            
            [PublicFunction showAlert:nil message:@"收藏成功" duration:5.0f];
            [self dismissContactView];
            
            
        }
        
        else {
            
            [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
            
            
        }
        
    } failureBlock:^(NSError *error) {
        
        NSLog(@"%@",error);
        
        [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
    }];

    
}
#pragma mark -------------项目更新-----
- (void)projectUpdate{

    [self dismissContactView];
    
    ProjectUpdateViewController *vc = [[ProjectUpdateViewController alloc] init];
    vc.crowd_id = self.crowd_id;
    [self.navigationController pushViewController:vc animated:YES];
    
    

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
